<?php if (!defined('__COLA_DIR__')) exit; ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="<?php $this->options->charset(); ?>">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title><?php $this->siteTitle(); ?></title>
    <?php $this->header(); ?>
</head>
<body>
<?php $WidgetMenu = $this->widget('Widget_Menu'); ?>
<div id="body" class="body with-leftCol">
	<div id="toolbar">
	    <div class="toolbarLeft">
		    <a href="<?php $this->options->ucenterUrl('index'); ?>" class="title">C<span class="so">O</span>LA</a>
		</div>
	    <div class="toolbarCenter">
		    <div class="drawer ci-menu" data-open-menu></div>
		    <div class="cola-title">
			    <?php $WidgetMenu->currentTitle(); ?>
                <?php if($WidgetMenu->currentAddLink): ?><a class="cola-addLink" href="<?php $WidgetMenu->currentAddLink(); ?>"><?php _e('新增'); ?></a><?php endif ?>    
			</div>
		</div>
		<div class="toolbarRight">
			<div class="other">
                <a href="<?php $this->options->siteUrl(); ?>"><i class="ci-home"></i></a>
				<a href="<?php $this->options->ucenterUrl('user-profile'); ?>"title="<?php $this->user->nickName(); ?> <?php
                            if ($this->user->logged > 0) {
                                $logged = new Date($this->user->logged);
                                _e('最后登录: %s', $logged->word());
                            }
                            ?>"><i class="ci-user"></i></a>
				<a class="logout" title="<?php _e('登出'); ?>" href="<?php $this->options->logoutUrl(); ?>"><i class="ci-logout"></i></a>
            </div>					
		</div>	
	</div>

	<div id="container">
	    <div class="backdrop" data-open-menu></div>
	    <div class="leftCol sidebar">
		    <div class="leftCol-body">
			    <div class="catalog-body">
                    <ul class="menu-accordion">
                        <?php $WidgetMenu->to($menu); ?>
                        <?php while($menu->next()): ?>
	                    <li class="parent-li<?php if($menu->current){ ?> active open<?php }; ?>">
					        <div class="parent-title">
						        <span class="icon ci-<?php $menu->icon(); ?>"></span>
					            <a class="parent-item<?php if($menu->current){ ?> active open<?php }; ?>" href="javascript:;"><?php $menu->name(); ?></a>
						    </div>
						    <ul class="child">
	                        <?php foreach ($menu->child as $value){ ?>
							    <li class="sub-li<?php if($value['current']){ ?> current<?php }; ?>">
		                            <a class="sub-item<?php if($value['current']){ ?> current<?php }; ?>" href="<?php echo $value['url']; ?>" title="<?php echo $value['title']; ?>"><?php echo $value['name']; ?></a>
	                            </li>
						    <?php }; ?>	
	                        </ul>
					    </li>
                        <?php endwhile; ?>
                    </ul>
			    </div>
		    </div>
	    </div>

        <div id="main" class="rightCol">
            <div class="content">
                <?php $this->layout(); ?>
            </div>
			
			<div class="copyright">
			        <?php _e('由 <a href="http://mcooo.com">%s</a> 强力驱动, 版本 %s', 'cola', $this->options->version); ?>
			</div>
	    </div>
    </div>
</div>
<?php $this->footer(); ?>

<script type="text/javascript">
$(document).ready(function() {
    $(document).on('click', '[data-open-menu]', function() {
         $('#body').toggleClass('with-leftCol');
    });
    var accordion_head = $('.leftCol .menu-accordion > li'),
	accordion_body = $('.leftCol .menu-accordion li > .child');
    accordion_head.on('click', function(event) {
	    if (!$(this).hasClass('active')){
		    accordion_body.slideUp('normal');
		    $(this).find('.child').stop(true,true).slideToggle('normal');
		    accordion_head.removeClass('active');
		    $(this).addClass('active');
	    }
    });
});
</script>
</body>
</html>